<?php
namespace app\admin\controller;

use app\admin\BaseController;
use think\facade\View;
use think\facade\Db;

class Index extends BaseController
{
	
	// 初始化
    protected function initialize()
    {
    	if(!session('?admin')){
    		return redirect('login/login');
    	}
    }
	
	
	/**
     * 后台首页
     * @access public
     */
    public function index()
    {   	
		$admin_id = session('admin');
		$admin = Db::name('admin')->where(['id'=>$admin_id])->find();
    	// 模板变量赋值
        View::assign('admin',$admin);
        View::assign('email','thinkphp@qq.com');
        return View::fetch('index/index');   		        
    }
    
	
    /**
     * 后台欢迎页
     * @access public
     */
    public function welcome()
    {
    	$admin_id = session('admin');
		$admin = Db::name('admin')->where(['id'=>$admin_id])->find();
		//系统信息
		$system = [
			//PHP版本
			'php_version' => PHP_VERSION,
			//PHP运行方式
			'php_mod' => php_sapi_name(),
			//当前域名
			'domain' => $this->request->domain(),
			//服务器操作系统
			'server_system' => php_uname(),
			//PHP运行环境
			'sysos' => $_SERVER["SERVER_SOFTWARE"],
		];
		
    	// 模板变量赋值
        View::assign('admin',$admin);
        View::assign('system',$system);
        return View::fetch('index/welcome');       
    }

    
}
